<script lang="ts" setup>
import { get, post, message, loadFile } from '@/utils'
import { FormInstance } from '@arco-design/web-vue'
import Upload from '@/components/upload/upload.vue'
const props = defineProps<{
  show: boolean
  id: string
}>()
const emit = defineEmits(['update:show', 'reset', 'confirm'])
const formRef = ref() as Ref<FormInstance>
const detail = reactive({
  code: props.id,
  url: '',
})
const submit = done => {
  console.log(detail)

  formRef.value.validate(err => {
    if (!err) {
      done(false)
      message({
        type: 'success',
        content: '获取到图片地址:' + detail.url,
        duration: 3000,
      })
    } else done(false)
  })
}
</script>
<template>
  <CModal v-model:visible="props.show" @before-ok="submit" :mask-closable="false" width="500px" title="调试" @cancel="emit('update:show', false)">
    <div class="content">
      <a-form :model="detail" ref="formRef" :label-col-props="{ span: 6 }" :wrapper-col-props="{ span: 16 }">
        <a-form-item label="资源编号" disabled field="code" :rules="[{ required: true, message: '请输入资源编号' }]" :validate-trigger="['change', 'blur']">
          <a-input v-model="detail.code" placeholder="请输入资源编号" />
        </a-form-item>
        <a-form-item label="上传文件" field="url" :rules="[{ required: true, message: '请上传文件' }]">
          <Upload :list="detail.url" v-model:value="detail.url" category-id="" api="/server-resource/oss/endpoint/put/file/debug" :form-data="{ code: detail.code }" />
        </a-form-item>
      </a-form>
    </div>
  </CModal>
</template>
<style lang="less" scoped></style>
